from timeit import Timer

import sys
import math


def Problem():
    """An irrational decimal fraction is created by concatenating the positive
    integers:

    0.123456789101112131415161718192021...

    It can be seen that the 12^(th) digit of the fractional part is 1.

    If d_(n) represents the n^(th) digit of the fractional part, 
    find the value of the following expression.

    d_(1) x d_(10) x d_(100) x d_(1000) x d_(10000) x d_(100000) x d_(1000000)
    """
    
            
    #Create the entire digit list/string - brute force
    digits = ''.join(map(str, range(1,1000000)))
    #Indicies of the digits we are interested in
    n_digit = [10 ** i - 1 for i in range(0, 7)]
    #Selected digits
    s_digit = [digits[n] for n in n_digit]
    #Product of digits
    ans = reduce(lambda x, y: int(x)*int(y), s_digit, 1)

    print "Answer for Problem 40 = %s " % (ans,)


    
if __name__ == "__main__":
    t = Timer(setup='from __main__ import Problem', stmt='Problem()').timeit(1)
    print "Execution time = %0.3f seconds" %(t,)